<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
<head>

    <jsp:include page="/WEB-INF/jsp/include/head.jsp"/>
</head>
<body>

<!-- 面包屑导航 -->
<ul class="breadcrumb">
    <li><strong>当前位置： </strong>系统管理</li>
    <li class="active">用户管理</li>
</ul>
<div class="panel panel-info">
    <div class="panel-heading">
        <h3 class="panel-title" style="display: inline-block">查询</h3>
        <a role="button" id="btn_add" style="float: right" class="btn btn-default btn-xs btn-info"
           href="javaScript:;"><span class="glyphicon glyphicon-plus-sign"></span>&nbsp;&nbsp;添&nbsp;加&nbsp</a>
    </div>
    <div class="panel-body">
        <form id="form_search" class="form-horizontal row">

            <div class="form-group col-sm-5">
                <label class="control-label col-sm-4 ">账号：</label>
                <div class="col-sm-6">
                    <input type="text" class="form-control" name="loginName">
                </div>
            </div>

            <div class="form-group col-sm-5">
                <label class="control-label col-sm-4 ">姓名：</label>
                <div class="col-sm-6">
                    <input type="text" class="form-control" name="name">
                </div>
            </div>

            <div class="form-group col-sm-5">
                <label class="col-sm-4 control-label">角色：</label>
                <div class="col-sm-6">
                    <select id="select_role" name="roleId">
                        <option value="">&nbsp;</option>
                    </select>
                </div>
            </div>

            <div class="form-group col-sm-5">
                <div class="col-sm-6 col-sm-offset-4">
                    <button id="btn_search" type="button" class="btn btn-default "><span
                            class="glyphicon glyphicon-search"></span>&nbsp;查&nbsp;询&nbsp;</button>
                </div>
            </div>
        </form>
    </div>
</div>

<table id="table_data"></table>

<div class="modal fade" id="modal_ajax">
    <div class="modal-dialog  ">
        <div class="modal-content ">
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<jsp:include page="/WEB-INF/jsp/include/footer.jsp"/>
<script>
    var $table = $('#table_data');
    $table.bootstrapTable({
        url: 'upms/account/select',
        striped: true,
        cache: false,
        pagination: true,
        sidePagination: "server",
        queryParams: function (params) {
            $.extend(params, $("#form_search").serializeObject());
            return params
        },
        columns: [
            {
                formatter: function (value, row, index) {
                    return index + 1;
                }
            }, {
                field: 'loginName',
                title: '账户'

            }, {
                field: 'name',
                title: '姓名 / 企业名称'

            }, {
                field: 'uniqueNumber',
                title: '身份证号 / 组织机构代码'

            }, {
                field: 'role',
                title: '角色',
                formatter: function (value, row, index) {
                    return value && value.name;
                }
            },
            {

                title: '所属',
                formatter: function (value, row, index) {
                    if (row.expertId != null) {
                        return "专家库"
                    } else if (row.staffId != null) {
                        return "员工库"
                    } else {
                        return "企业库"
                    }
                }
            },
//            {
//                field: 'live',
//                title: '状态',
//                formatter: function (value, row, index) {
//                    return $.sysPlugin.ifElse(value, $.sysPlugin.enumeration.live);
//                }
//            },
            {
                title: '操作',
                events: 'Events',
                formatter: function (value, row, index) {
                    return [
                        '<div class="btn-group btn-group-xs" role="group" >' +
                        '<button type="button" class="btn btn-xs btn-default update-data">' +
                        '<span class="glyphicon glyphicon-edit  "></span> 修改' +
                        '</button>' +
                        '<button type="button" class="btn btn-xs btn-default updatePassword-data">' +
                        '<span class="glyphicon glyphicon-repeat"></span> 重置密码' +
                        '</button>' +
                        '</div>'
                    ].join('');
                }
            }
        ]
    });
    window.Events = {
        'click .update-data': function (e, value, row, index) {
            $('#modal_ajax').modal({
                backdrop: 'static',
                keyboard: false,
                show: true,
                remote: 'upms/account/editDlg?id=' + row.id
            });
        },
        'click .updatePassword-data': function (e, value, row, index) {
            $('#modal_ajax').modal({
                backdrop: 'static',
                keyboard: false,
                show: true,
                remote: 'upms/account/updatePasswordDlg?id=' + row.id
            });
        }
    };

    $("#btn_add").click(function () {
        $('#modal_ajax').modal({
            backdrop: 'static',
            keyboard: false,
            show: true,
            remote: 'upms/account/editDlg'
        });
    });

    $("#btn_search").click(function () {
        $table.bootstrapTable("refresh");
    });


    $.sysPlugin.initSelect2($('#select_role'), {
        url: "upms/role/selectRoleAll"
    });


    $.sysPlugin.clearModalRemoveData("modal_ajax");

    $.sysPlugin.initDateTimeInput();


</script>


</body>
</html>